Nikita Baksalyar [Thu, 16 Jun 2016 05:25:18 +0000 (05:25 +0000)]
Fix POSIX shell in the configure script
bors [Fri, 26 Aug 2016 21:43:13 +0000 (14:43 -0700)]
Auto merge of #3047 - alexcrichton:update-libz, r=alexcrichton
Update libz-sys to 1.0.6
Fixes a build error on OSX
Closes #3037
Alex Crichton [Fri, 26 Aug 2016 21:42:40 +0000 (14:42 -0700)]
Update libz-sys to 1.0.6
Fixes a build error on OSX
Closes #3037
bors [Fri, 26 Aug 2016 19:48:17 +0000 (12:48 -0700)]
Auto merge of #3040 - matklad:rootless-readlockfile, r=alexcrichton
Don't use current package when reading lockfile
Looks like this `default` thing is basically a hack, which is fired when the lockfile references some package which is no longer present. That is, if I remove `default` and just `unwrap` source id, the only test which fails is `git_with_lockfile` because it has a typo in the lockfile.
So I've just changed the `default` to some dummy path. Perhaps a more correct solution would be to ignore such packages completely when loading lockfile.
bors [Fri, 26 Aug 2016 15:56:44 +0000 (08:56 -0700)]
Auto merge of #3044 - jeandudey:unused-code, r=alexcrichton
Remove unused macro (configure_shell)
Also i've removed some unused lints on sha256.rs
Jean Pierre Dudey [Fri, 26 Aug 2016 12:01:07 +0000 (08:01 -0400)]
Remove unused macro (configure_shell)
Also i've removed some unused lints on sha256.rs
Aleksey Kladov [Fri, 26 Aug 2016 09:34:17 +0000 (12:34 +0300)]
Refactor EncodableResolve::into_resolve
bors [Thu, 25 Aug 2016 17:44:25 +0000 (10:44 -0700)]
Auto merge of #3039 - matklad:test-lockfiles, r=alexcrichton
Simplify lockfile tests
Use project builder to create a file and an extension function to read it.
Aleksey Kladov [Thu, 25 Aug 2016 08:34:25 +0000 (11:34 +0300)]
Simplify lockfile tests
Aleksey Kladov [Thu, 25 Aug 2016 10:10:45 +0000 (13:10 +0300)]
Don't use current package when reading lockfile
bors [Tue, 23 Aug 2016 22:02:37 +0000 (15:02 -0700)]
Auto merge of #3021 - alexcrichton:test-release-panic-abort, r=brson
Fix transitive doctests panic=abort
Ensure that when we compile doctested libraries or examples we use the same
panic mode as the rest of the tests, namely ignoring panic=abort b/c libtest
isn't compiled with panic=abort.
Closes #3017
bors [Tue, 23 Aug 2016 20:57:48 +0000 (13:57 -0700)]
Auto merge of #3031 - matklad:lockfile-test, r=alexcrichton
Lockfile test
Aleksey Kladov [Mon, 22 Aug 2016 23:59:31 +0000 (02:59 +0300)]
Regression test for lockfile format
bors [Mon, 22 Aug 2016 16:07:04 +0000 (09:07 -0700)]
Auto merge of #3029 - matklad:workspace-overrides, r=alexcrichton
Don't special case root package for overrides
Hi! What is the expected behavior of path overrides and workspaces? There are some [tests] for this, but looks like they don't actually test the behavior: this commit removes special casing of the root package, but `override_self` still passes. I see two options:
1. Allow overriding of the workspace members as usual. This amounts to removing that `filter`
2. Ignore overriding of the workspace members.
In any case, I think it would be nice to add a test which overrides local package to some other package to make sure that test does not pass simply because the package and its override are in fact the same.
[tests]: https://github.com/rust-lang/cargo/blob/master/tests/path.rs#L599-L679
Aleksey Kladov [Mon, 22 Aug 2016 12:07:18 +0000 (15:07 +0300)]
Don't special case root package for overrides
bors [Sun, 21 Aug 2016 17:37:40 +0000 (10:37 -0700)]
Auto merge of #3026 - whitequark:patch-1, r=alexcrichton
doc: fix platform-specific definitions section
Right now the section seems to imply that using cfg(target_pointer_width = "32")
is an acceptable way to detect whether the crate should be built for x86.
Aleksey Kladov [Sat, 20 Aug 2016 21:27:06 +0000 (00:27 +0300)]
Forward compatibility with rootless lockfiles
whitequark [Sat, 20 Aug 2016 17:41:37 +0000 (17:41 +0000)]
doc: fix platform-specific definitions section
Right now the section seems to imply that using cfg(target_pointer_width = "32")
is an acceptable way to detect whether the crate is built for x86.
bors [Fri, 19 Aug 2016 21:24:29 +0000 (14:24 -0700)]
Auto merge of #3022 - alexcrichton:add-more-metadata, r=brson
Add a temporary env var to enable hashes in filenames
For rustbuild we need the hashes to exist for all deps, even if they're path
deps, because we care about the actual file names. For example we don't want to
install /usr/lib/libstd.so!
This adds a "secret" environment variable, `__CARGO_DEFAULT_LIB_METADATA` which
re-enables the old behavior of just putting hashes in filenames.
Closes #3005
Alex Crichton [Fri, 19 Aug 2016 20:36:32 +0000 (13:36 -0700)]
Add a temporary env var to enable hashes in filenames
For rustbuild we need the hashes to exist for all deps, even if they're path
deps, because we care about the actual file names. For example we don't want to
install /usr/lib/libstd.so!
This adds a "secret" environment variable, `__CARGO_DEFAULT_LIB_METADATA` which
re-enables the old behavior of just putting hashes in filenames.
Closes #3005
bors [Fri, 19 Aug 2016 20:44:26 +0000 (13:44 -0700)]
Auto merge of #3020 - tshepang:rustfmt-cargo_doc, r=alexcrichton
rustfmt cargo_doc.rs
Alex Crichton [Fri, 19 Aug 2016 20:25:13 +0000 (13:25 -0700)]
Fix transitive doctests panic=abort
Ensure that when we compile doctested libraries or examples we use the same
panic mode as the rest of the tests, namely ignoring panic=abort b/c libtest
isn't compiled with panic=abort.
Closes #3017
Tshepang Lekhonkhobe [Fri, 19 Aug 2016 20:18:57 +0000 (22:18 +0200)]
rustfmt cargo_doc.rs
bors [Fri, 19 Aug 2016 19:02:25 +0000 (12:02 -0700)]
Auto merge of #3019 - matklad:rootless-resolve_ws, r=alexcrichton
Don't require current package in resolve_ws
Aleksey Kladov [Fri, 19 Aug 2016 18:00:21 +0000 (21:00 +0300)]
Don't require current package in resolve_ws
bors [Fri, 19 Aug 2016 16:35:26 +0000 (09:35 -0700)]
Auto merge of #3018 - Jake-Shadle:master, r=steveklabnik
docs(manifest): Update crate-types with `cdylib`
Rust 1.11 now supports the `cdylib` crate-type, so added it to the list of options.
Also added a link to the [Linkage](https://doc.rust-lang.org/reference.html#linkage) section in the Rust Reference manual which explains what the different crate types actually mean in practice....though right now it actually doesn't explain what a `cdylib` is, specifically. ;)
Jake Shadle [Fri, 19 Aug 2016 16:32:22 +0000 (18:32 +0200)]
docs(manifest): Remove 1.11 reference
Jake Shadle [Fri, 19 Aug 2016 16:21:43 +0000 (18:21 +0200)]
docs(manifest): Update crate-types with `cdylib`
Rust 1.11 now supports the `cdylib` crate-type, so added it to the
list of options. Also added a link to the
[Linkage](https://doc.rust-lang.org/reference.html#linkage) section
in the Rust Reference manual which explains what the different
crate types actually mean in practice....though right now it actually
doesn't explain what a `cdylib` is, specifically. ;)
bors [Thu, 18 Aug 2016 19:54:46 +0000 (12:54 -0700)]
Auto merge of #3013 - matklad:rootless-resolve, r=alexcrichton
Rootless resolve
This should help to make more commands applicable to the whole workspace. Though there is apparently a ton of work to make `cargo metadata` work with workspaces.
This does not support rootless lockfiles. Will do this in a separate PR.
Aleksey Kladov [Wed, 17 Aug 2016 22:01:19 +0000 (01:01 +0300)]
Remove root field from Resolve.
Aleksey Kladov [Wed, 17 Aug 2016 20:31:29 +0000 (23:31 +0300)]
Don't use Resolve.root when checking for cycles
Aleksey Kladov [Wed, 17 Aug 2016 23:34:20 +0000 (02:34 +0300)]
Don't use Resolve.root in cargo metadata
Aleksey Kladov [Wed, 17 Aug 2016 19:20:09 +0000 (22:20 +0300)]
Add current_package to the Context
bors [Thu, 18 Aug 2016 15:47:35 +0000 (08:47 -0700)]
Auto merge of #3015 - tshepang:match-block-not-needed, r=alexcrichton
match block not needed
bors [Thu, 18 Aug 2016 15:06:09 +0000 (08:06 -0700)]
Auto merge of #3007 - whitequark:opt-level-s, r=alexcrichton
Allow using opt-level="s"/"z" in profile overrides
Initially, I've considered making a dedicated `OptLevel` enum, but this appeared to bring no practical benefit, only boilerplate, so I've used a String instead, which is also in line with the `u32` that was there before, not even checked for being in range `0...3`.
Tshepang Lekhonkhobe [Thu, 18 Aug 2016 06:49:07 +0000 (08:49 +0200)]
Merge branch 'master' into match-block-not-needed
Tshepang Lekhonkhobe [Thu, 18 Aug 2016 06:46:42 +0000 (08:46 +0200)]
match block not needed
whitequark [Wed, 17 Aug 2016 07:35:57 +0000 (07:35 +0000)]
Allow using opt-level="s"/"z" in profile overrides.
Fixes #2655.
bors [Wed, 17 Aug 2016 19:02:10 +0000 (12:02 -0700)]
Auto merge of #3010 - steveklabnik:gh3001, r=alexcrichton
Revert to previous semver version.
As it turns out, people were taking advantage of bugginess in semver, so
we can't do this upgrade yet.
Fixes #3001
bors [Wed, 17 Aug 2016 17:57:29 +0000 (10:57 -0700)]
Auto merge of #3011 - alexcrichton:new-openssl, r=alexcrichton
Change download source for OpenSSL
Apparently they now redirect openssl.org to www.openssl.org
Alex Crichton [Wed, 17 Aug 2016 17:56:43 +0000 (10:56 -0700)]
Change download source for OpenSSL
Apparently they now redirect openssl.org to www.openssl.org
Steve Klabnik [Wed, 17 Aug 2016 14:10:10 +0000 (10:10 -0400)]
Revert to previous semver version.
As it turns out, people were taking advantage of bugginess in semver, so
we can't do this upgrade yet.
Fixes #3001
bors [Tue, 16 Aug 2016 21:11:32 +0000 (14:11 -0700)]
Auto merge of #3002 - untitaker:trunchate-cargo-config, r=alexcrichton
Trunchate cargo config properly
None
Markus Unterwaditzer [Tue, 16 Aug 2016 20:51:08 +0000 (22:51 +0200)]
Trunchate cargo config properly
bors [Mon, 15 Aug 2016 21:13:39 +0000 (14:13 -0700)]
Auto merge of #2991 - matklad:deadlocks, r=alexcrichton
Deadlocks with git dependencies
Only a test for now to verify that it actually fails on Travis.
Hopefully will close #2987
Aleksey Kladov [Mon, 15 Aug 2016 10:48:40 +0000 (13:48 +0300)]
Use a single lock for all git repositories
bors [Mon, 15 Aug 2016 19:05:55 +0000 (12:05 -0700)]
Auto merge of #2994 - krbullock:fix/document-vcs-hg-config, r=alexcrichton
Document ability to configure `cargo-new.vcs = "hg"`
Kevin Bullock [Mon, 15 Aug 2016 18:36:49 +0000 (13:36 -0500)]
Document ability to configure `cargo-new.vcs = "hg"`
Aleksey Kladov [Sun, 14 Aug 2016 23:04:07 +0000 (02:04 +0300)]
Add a test for #2987
bors [Sun, 14 Aug 2016 07:07:46 +0000 (00:07 -0700)]
Auto merge of #2988 - lifthrasiir:doc-open-with-target, r=alexcrichton
Make `cargo doc --open --target TARGET` work as expected.
Currently `cargo doc --open` opens `$TARGET/doc` unconditionally, but it is incorrect if the explicit target is specified.
The target directory should be same to what `Layout::new()` generates, and ideally it should use the same data source (it hadn't been so far), but I'm yet to find a good way to signal that. At least I'm pretty sure that `Compilation` is not a good position to put them (it assumes the bipartite "root"-"deps" separation which doesn't quite work in documentation).
Kang Seonghoon [Sat, 13 Aug 2016 21:30:02 +0000 (06:30 +0900)]
Make `cargo doc --open --target TARGET` work as expected.
bors [Tue, 9 Aug 2016 18:17:13 +0000 (11:17 -0700)]
Auto merge of #2978 - matklad:opt-level, r=alexcrichton
Gracefully handle errors in a lockfile
Closes #2715
Question: why internal errors are hidden by default? I think if the unexpected has happened you most likely want to know some details. See also #2756.
bors [Tue, 9 Aug 2016 16:25:54 +0000 (09:25 -0700)]
Auto merge of #2979 - jonathandturner:prepare_for_new_format, r=alexcrichton
Update cargo tests in prep for new errors
This updates a couple tests so that we can upgrade rustc to new error format.
r? @alexcrichton
Jonathan Turner [Tue, 9 Aug 2016 16:23:52 +0000 (09:23 -0700)]
Update cargo tests in prep for new errors
Aleksey Kladov [Tue, 9 Aug 2016 13:11:20 +0000 (16:11 +0300)]
Don't panic because of invalid source
Aleksey Kladov [Tue, 9 Aug 2016 12:14:26 +0000 (15:14 +0300)]
Gracefully handle duplicate package in a lockfile
bors [Tue, 9 Aug 2016 02:10:55 +0000 (19:10 -0700)]
Auto merge of #2974 - alexcrichton:etag, r=brson
Speed up noop registry updates with GitHub
This commit adds supports to registry index updates to use GitHub's HTTP API [1]
which is purportedly [2] much faster than doing a git clone, and emprically that
appears to be the case.
This logic kicks in by looking at the URL of a registry's index, and if it looks
exactly like `github.com/$user/$repo` then we'll attempt to use GitHub's API,
otherwise we always fall back to a git update.
This behavior may *slow down* registry updates which actually need to download
information as an extra HTTP request is performed to figure out that we need to
perform a git fetch, but hopefully that won't actually be the case much of the
time!
[1]: https://developer.github.com/v3/repos/commits/#get-the-sha-1-of-a-commit-reference
[2]: https://developer.github.com/changes/2016-02-24-commit-reference-sha-api/
Closes https://github.com/rust-lang/cargo/issues/2451
bors [Mon, 8 Aug 2016 18:14:09 +0000 (11:14 -0700)]
Auto merge of #2973 - alexcrichton:update-deps, r=alexcrichton
Update dependencies in Cargo.lock
A few bug fixes here and there we'll pick up (e.g. the gcc crate on newer MSVC
versions), but otherwise just staying on top of things.
Alex Crichton [Tue, 12 Jul 2016 16:36:33 +0000 (09:36 -0700)]
Speed up noop registry updates with GitHub
This commit adds supports to registry index updates to use GitHub's HTTP API [1]
which is purportedly [2] much faster than doing a git clone, and emprically that
appears to be the case.
This logic kicks in by looking at the URL of a registry's index, and if it looks
exactly like `github.com/$user/$repo` then we'll attempt to use GitHub's API,
otherwise we always fall back to a git update.
This behavior may *slow down* registry updates which actually need to download
information as an extra HTTP request is performed to figure out that we need to
perform a git fetch, but hopefully that won't actually be the case much of the
time!
[1]: https://developer.github.com/v3/repos/commits/#get-the-sha-1-of-a-commit-reference
[2]: https://developer.github.com/changes/2016-02-24-commit-reference-sha-api/
Alex Crichton [Sun, 7 Aug 2016 08:15:15 +0000 (01:15 -0700)]
Update dependencies in Cargo.lock
A few bug fixes here and there we'll pick up (e.g. the gcc crate on newer MSVC
versions), but otherwise just staying on top of things.
bors [Mon, 8 Aug 2016 17:37:17 +0000 (10:37 -0700)]
Auto merge of #2871 - QuiltOS:doc-build-deps, r=alexcrichton
Better rational for build-dependencies and other kinds being disjoint.
The old reason was bad because nothing prevents normal dependencies from
being built before the build script.
bors [Sun, 7 Aug 2016 06:35:42 +0000 (23:35 -0700)]
Auto merge of #2954 - alexcrichton:panic-abort-plugins, r=brson
Fix panic=abort when compiling with plugins
Closes #2738
bors [Sun, 7 Aug 2016 03:01:34 +0000 (20:01 -0700)]
Auto merge of #2970 - jirutka:fix-musl-nfs, r=alexcrichton
Disable is_on_nfs_mount() check on musl libc (fixes #2937)
musl libc doesn't provide constant NFS_SUPER_MAGICK that is used in the is_on_nfs_mount function.
bors [Sun, 7 Aug 2016 02:20:17 +0000 (19:20 -0700)]
Auto merge of #2967 - frewsxcv:clippy, r=alexcrichton
Address some clippy lints.
None
bors [Sun, 7 Aug 2016 01:13:13 +0000 (18:13 -0700)]
Auto merge of #2971 - alexcrichton:openssl-init, r=alexcrichton
Update OpenSSL-using dependencies
They've all been updated to canonicalize as `openssl_sys::init` as the "one true
method" for initializing OpenSSL,
Closes #2961
Alex Crichton [Sun, 7 Aug 2016 00:49:32 +0000 (17:49 -0700)]
Update OpenSSL-using dependencies
They've all been updated to canonicalize as `openssl_sys::init` as the "one true
method" for initializing OpenSSL,
Closes #2961
Jakub Jirutka [Sun, 7 Aug 2016 00:22:00 +0000 (02:22 +0200)]
Disable is_on_nfs_mount() check on musl libc (fixes #2937)
musl libc doesn't provide constant NFS_SUPER_MAGICK that is used in
the is_on_nfs_mount function.
Corey Farwell [Sat, 6 Aug 2016 02:44:17 +0000 (22:44 -0400)]
Combine duplicate `if` arm blocks.
Corey Farwell [Sat, 6 Aug 2016 02:31:19 +0000 (22:31 -0400)]
Use `char` when using single character as `Pattern`.
Corey Farwell [Sat, 6 Aug 2016 02:15:27 +0000 (22:15 -0400)]
Remove unnecessary usages of `format!` macro.
bors [Fri, 5 Aug 2016 16:13:51 +0000 (09:13 -0700)]
Auto merge of #2962 - alexcrichton:demote-error, r=brson
Demote duplicate build target error to a warning
Added in #2847 this ended up unfortunately breaking the `regex` crate on
nightly, so let's just issue a warning for awhile first. Eventually we can
promote this to an error if it becomes a problem.
Alex Crichton [Fri, 5 Aug 2016 16:07:18 +0000 (09:07 -0700)]
Demote duplicate build target error to a warning
Added in #2847 this ended up unfortunately breaking the `regex` crate on
nightly, so let's just issue a warning for awhile first. Eventually we can
promote this to an error if it becomes a problem.
bors [Fri, 5 Aug 2016 06:10:40 +0000 (23:10 -0700)]
Auto merge of #2957 - mattico:patch-1, r=alexcrichton
Fix typos in source-replacement docs
bors [Fri, 5 Aug 2016 02:51:13 +0000 (19:51 -0700)]
Auto merge of #2960 - jseyfried:remove_unused_import, r=alexcrichton
Remove another unused import
Ideally, this would have been in #2942.
Jeffrey Seyfried [Thu, 4 Aug 2016 22:12:35 +0000 (22:12 +0000)]
Remove unused import.
Matt Ickstadt [Thu, 4 Aug 2016 21:41:58 +0000 (16:41 -0500)]
Fix typos
bors [Thu, 4 Aug 2016 06:40:40 +0000 (23:40 -0700)]
Auto merge of #2847 - munyari:build_targets, r=alexcrichton
Warn about duplicated build targets
I basically wholesale copied `unique_names_in_targets` into a different `unique_build_targets` because of the different types. Is there any way I could have just used the existing functionality?
Alex Crichton [Thu, 4 Aug 2016 03:36:28 +0000 (20:36 -0700)]
Fix panic=abort when compiling with plugins
Closes #2738
Panashe M. Fundira [Sun, 10 Jul 2016 17:29:31 +0000 (13:29 -0400)]
Warn about duplicated build targets
bors [Tue, 2 Aug 2016 18:12:04 +0000 (11:12 -0700)]
Auto merge of #2946 - alexcrichton:build-script-metadata, r=brson
Always pass `-C metadata` to the compiler
If it's not otherwise available we just key it off the pkgid which should be
unique enough across compilations. This should help incremental compilation
efforts be "more incremental" across projects.
Closes #2943
Alex Crichton [Tue, 2 Aug 2016 06:22:29 +0000 (23:22 -0700)]
Always pass `-C metadata` to the compiler
If it's not otherwise available we just key it off the pkgid which should be
unique enough across compilations. This should help incremental compilation
efforts be "more incremental" across projects.
Closes #2943
bors [Mon, 1 Aug 2016 23:59:38 +0000 (16:59 -0700)]
Auto merge of #2857 - alexcrichton:redirect-sources, r=brson
Add support local mirrors of registries, take 2
This series of commits culminates in first class support in Cargo for local mirrors of registries. This is implemented through a number of other more generic mechanisms, and extra support was added along the way. The highlights of this PR, however, are:
New `.cargo/config` keys have been added to enable *replacing one source with another*. This functionality is intended to be used for mirrors of the main registry or otherwise one to one source correspondences. The support looks like:
```toml
[source.crates-io]
replace-with = 'my-awesome-registry'
[source.my-awesome-registry]
registry = 'https://github.com/my-awesome/registry-index'
```
This configuration means that instead of using `crates-io` (e.g. `https://github.com/rust-lang/crates.io-index`), Cargo will query the `my-awesome-registry` source instead (configured to a different index here). This alternate source **must be the exact same as the crates.io index**. Cargo assumes that replacement sources are exact 1:1 mirrors in this respect, and the following support is designed around that assumption.
When generating a lock file for crate using a replacement registry, the *original registry* will be encoded into the lock file. For example in the configuration above, all lock files will still mention crates.io as the registry that packages originated from. This semantically represents how crates.io is the source of truth for all crates, and this is upheld because all replacements have a 1:1 correspondance.
Overall, this means that no matter what replacement source you're working with, you can ship your lock file to anyone else and you'll all still have verifiably reproducible builds!
With the above support for custom registries, it's now possible for a project to be downloading crates from any number of sources. One of Cargo's core goals is reproducible builds, and with all these new sources of information it may be easy for a few situations to arise:
1. A local replacement of crates.io could be corrupt
2. A local replacement of crates.io could have made subtle changes to crates
In both of these cases, Cargo would today simply give non-reproducible builds. To help assuage these concerns, Cargo will now track the sha256 checksum of all crates from registries in the lock file. Whenever a `Cargo.lock` is generated from now on it will contain a `[metadata]` section which lists the sha256 checksum of all crates in the lock file (or `<none>` if the sha256 checksum isn't known).
Cargo already checks registry checksums against what's actually downloaded, and Cargo will now verify between iterations of the lock file that checksums remain the same as well. This means that if a local replacement registry is **not** in a 1:1 correspondance with crates.io, the lock file will prevent the build from progressing until the discrepancy is resolved.
In addition to the support above, there is now a new kind of source in Cargo, a "local registry", which is intended to be a subset of the crates.io ecosystem purposed for a local build for any particular project here or there. The way to enable this looks like:
```toml
[source.crates-io]
replace-with = 'my-awesome-registry'
[source.my-awesome-registry]
local-registry = 'path/to/my/local/registry'
```
This local registry is expected to have two components:
1. A directory called `index` which matches the same structure as the crates.io index. The `config.json` file is not required here.
2. Inside the registry directory are any number of `.crate` files (downloaded from crates.io). Each crate file has the name `<package>-<version>.crate`.
This local registry must currently be managed manually, but I plan on publishing and maintaining a Cargo subcommand to manage a local registry. It will have options to do things like:
1. Sync a local registry with a `Cargo.lock`
2. Add a registry package to a local registry
3. Remove a package from a local registry
In addition to local registries, Cargo also supports a "directory source" like so
```toml
[source.crates-io]
replace-with = 'my-awesome-registry'
[source.my-awesome-registry]
directory = 'path/to/some/sources'
```
A directory source is similar to a local registry above, except that all the crates are unpacked and visible as vendored source. This format is suitable for checking into source trees, like Gecko's.
Unlike local registries above we don't have a tarball to verify the crates.io checksum with, but each vendored dependency has metadata containing what it *would* have been. To further prevent modifications by accident, the metadata contains the checksum of each file which should prevent accidental local modifications and steer towards `[replace]` as the mechanism to edit dependencies if necessary.
This is quite a bit of new features! What's all this meant to do? Some example scenarios that this is envisioned to solve are:
1. Supporting mirrors for crates.io in a first class fashion. Once we have the ability to spin up your own local registry, it should be easy to locally select a new mirror.
2. Supporting round-robin mirrors, this provides an easy vector for configuration of "instead of crates.io hit the first source in this list that works"
3. Build environments where network access is not an option. Preparing a local registry ahead-of-time (from a known good lock file) will be a vector to ensure that all Rust dependencies are locally available.
* Note this is intended to include use cases like Debian and Gecko
Even with the new goodies here, there's some more vectors through which this can be expanded:
* Support for running your own mirror of crates.io needs to be implemented to be "easy to do". There should for example be a `cargo install foo` available to have everything "Just Work".
* Replacing a source with a list of sources (attempted in round robin fashion) needs to be implemented
* Eventually this support will be extended to the `Cargo.toml` file itself. For example:
* packages should be downloadable from multiple registries
* replacement sources should be encodable into `Cargo.toml` (note that these replacements, unlike the ones above, would be encoded into `Cargo.lock`)
* adding multiple mirrors to a `Cargo.toml` should be supported
* Implementing the subcommand above to manage local registries needs to happen (I will attend to this shortly)
bors [Mon, 1 Aug 2016 22:56:32 +0000 (15:56 -0700)]
Auto merge of #2945 - QuiltOS:openssl, r=alexcrichton
Use openssl on Unix rather than C functions directly for SHA256
Takes on an extra dependency, but removes unsafe code in the process.
@alexcrichton I was a little confused by what you were saying on IRC, so I went ahead and just speculatively made this. No worries if it is no good.
John Ericson [Mon, 1 Aug 2016 20:28:25 +0000 (13:28 -0700)]
Use openssl on Unix rather than C functions directly for SHA256
Alex Crichton [Mon, 1 Aug 2016 18:40:01 +0000 (11:40 -0700)]
Add documentation for source replacement
bors [Mon, 1 Aug 2016 18:33:21 +0000 (11:33 -0700)]
Auto merge of #2942 - jseyfried:remove_unused_import, r=alexcrichton
Remove unused import
c.f. https://github.com/rust-lang/rust/pull/35116
Jeffrey Seyfried [Mon, 1 Aug 2016 18:30:46 +0000 (18:30 +0000)]
Remove unused import
Alex Crichton [Tue, 26 Jul 2016 22:23:20 +0000 (15:23 -0700)]
Addressing review comments
Alex Crichton [Tue, 5 Jul 2016 17:28:51 +0000 (10:28 -0700)]
Implement a directory source
This flavor of source is intended to behave like a local registry except that
its contents are unpacked rather than zipped up in `.crate` form. Like with
local registries the only way to use this currently is via the
`.cargo/config`-based source replacement currently, and primarily only to
replace crates.io or other registries at the moment.
A directory source is simply a directory which has many `.crate` files unpacked
inside of it. The directory is not recursively traversed for changes, but rather
it is just required that all elements in the directory are themselves
directories of packages.
This format is more suitable for checking into source trees, and it still
provides guarantees around preventing modification of the original source from
the upstream copy. Each directory in the directory source is required to have a
`.cargo-checksum.json` file indicating the checksum it *would* have had if the
crate had come from the original source as well as all of the sha256 checksums
of all the files in the repo. It is intended that directory sources are
assembled from a separately shipped subcommand (e.g. `cargo vendor` or `cargo
local-registry`), so these checksum files don't have to be managed manually.
Modification of a directory source is not the intended purpose, and if a
modification is detected then the user is nudged towards solutions like
`[replace]` which are intended for overriding other sources and processing local
modifications.
Alex Crichton [Fri, 5 Feb 2016 23:14:17 +0000 (15:14 -0800)]
Implement a local registry type
This flavor of registry is intended to behave very similarly to the standard
remote registry, except everything is contained locally on the filesystem
instead. There are a few components to this new flavor of registry:
1. The registry itself is rooted at a particular directory, owning all structure
beneath it.
2. There is an `index` folder with the same structure as the crates.io index
describing the local registry (e.g. contents, versions, checksums, etc).
3. Inside the root will also be a list of `.crate` files which correspond to
those described in the index. All crates must be of the form
`name-version.crate` and be the same `.crate` files from crates.io itself.
This support can currently be used via the previous implementation of source
overrides with the new type:
```toml
[source.crates-io]
replace-with = 'my-awesome-registry'
[source.my-awesome-registry]
local-registry = 'path/to/registry'
```
I will soon follow up with a tool which can be used to manage these local
registries externally.
Alex Crichton [Fri, 5 Feb 2016 23:11:07 +0000 (15:11 -0800)]
Refactor the RegistrySource implementation
Add an abstraction over which the index can be updated and downloads can be
made. This is currently implemented for "remote" registries (e.g. crates.io),
but soon there will be one for "local" registries as well.
Alex Crichton [Wed, 3 Feb 2016 19:04:07 +0000 (11:04 -0800)]
Add sha256 checksums to the lockfile
This commit changes how lock files are encoded by checksums for each package in
the lockfile to the `[metadata]` section. The previous commit implemented the
ability to redirect sources, but the core assumption there was that a package
coming from two different locations was always the same. An inevitable case,
however, is that a source gets corrupted or, worse, ships a modified version of
a crate to introduce instability between two "mirrors".
The purpose of adding checksums will be to resolve this discrepancy. Each crate
coming from crates.io will now record its sha256 checksum in the lock file. When
a lock file already exists, the new checksum for a crate will be checked against
it, and if they differ compilation will be aborted. Currently only registry
crates will have sha256 checksums listed, all other sources do not have
checksums at this time.
The astute may notice that if the lock file format is changing, then a lock file
generated by a newer Cargo might be mangled by an older Cargo. In anticipation
of this, however, all Cargo versions published support a `[metadata]` section of
the lock file which is transparently carried forward if encountered. This means
that older Cargos compiling with a newer lock file will not verify checksums in
the lock file, but they will carry forward the checksum information and prevent
it from being removed.
There are, however, a few situations where problems may still arise:
1. If an older Cargo takes a newer lockfile (with checksums) and updates it with
a modified `Cargo.toml` (e.g. a package was added, removed, or updated), then
the `[metadata]` section will not be updated appropriately. This modification
would require a newer Cargo to come in and update the checksums for such a
modification.
2. Today Cargo can only calculate checksums for registry sources, but we may
eventually want to support other sources like git (or just straight-up path
sources). If future Cargo implements support for this sort of checksum, then
it's the same problem as above where older Cargos will not know how to keep
the checksum in sync
Alex Crichton [Wed, 3 Feb 2016 18:54:07 +0000 (10:54 -0800)]
Implement source redirection
This commit implements a scheme for .cargo/config files where sources can be
redirected to other sources. The purpose of this will be to override crates.io
for a few use cases:
* Replace it with a mirror site that is sync'd to crates.io
* Replace it with a "directory source" or some other local source
This major feature of this redirection, however, is that none of it is encoded
into the lock file. If one source is redirected to another then it is assumed
that packages from both are exactly the same (e.g. `foo v0.0.1` is the same in
both location). The lock file simply encodes the canonical soure (e.g.
crates.io) rather than the replacement source. In the end this means that
Cargo.lock files can be generated from any replacement source and shipped to
other locations without the lockfile oscillating about where packages came from.
Eventually this support will be extended to `Cargo.toml` itself (which will be
encoded into the lock file), but that support is not implemented today. The
syntax for what was implemented today looks like:
# .cargo/config
[source.my-awesome-registry]
registry = 'https://example.com/path/to/index'
[source.crates-io]
replace-with = 'my-awesome-registry'
Each source will have a canonical name and will be configured with the various
keys underneath it (today just 'registry' and 'directory' will be accepted). The
global `crates-io` source represents crates from the standard registry, and this
can be replaced with other mirror sources.
All tests have been modified to use this new infrastructure instead of the old
`registry.index` configuration. This configuration is now also deprecated and
will emit an unconditional warning about how it will no longer be used in the
future.
Finally, all subcommands now use this "source map" except for `cargo publish`,
which will always publish to the default registry (in this case crates.io).
Alex Crichton [Tue, 2 Feb 2016 17:37:02 +0000 (09:37 -0800)]
Improve Debug for PackageId
Alex Crichton [Tue, 2 Feb 2016 17:36:29 +0000 (09:36 -0800)]
Add convenience helpers to map source ids
Should help easily mapping packages from one source to another
Alex Crichton [Tue, 2 Feb 2016 17:31:53 +0000 (09:31 -0800)]
Get Box<Source> to implement Source
Alex Crichton [Mon, 1 Feb 2016 21:34:02 +0000 (13:34 -0800)]
Remove some dead code
Alex Crichton [Mon, 1 Feb 2016 21:30:43 +0000 (13:30 -0800)]
Refactor URL parsing, be more robust for decoding errors
URL parsing now returns a `CargoResult` and also change a few `unwrap()` calls
to returning a `CargoResult` when decoding various bits and pieces of
information.
bors [Mon, 1 Aug 2016 15:51:40 +0000 (08:51 -0700)]
Auto merge of #2940 - matklad:ambiguous-deps, r=alexcrichton
Warn about unused keys in dependency specification
Closes #2869 and #2695
Aleksey Kladov [Mon, 1 Aug 2016 13:36:29 +0000 (16:36 +0300)]
Warn about unused keys in dependency specification